// Copyright Leonid Shlyapnikov 2010
// Distributed under the GNU Lesser General Public License http://www.gnu.org/licenses/lgpl.html
//    author: Leonid Shlyapnikov, created on: Jul 11, 2010

#ifndef FIXPARSER_CPP_SRC_MAIN_FIXPARSER_CHECKSUMCONVERTER_H_
#define FIXPARSER_CPP_SRC_MAIN_FIXPARSER_CHECKSUMCONVERTER_H_

#include <boost/utility.hpp>

namespace fixparser {

class ChecksumConverter: boost::noncopyable{
public:
    static const ChecksumConverter& instance() {
        static ChecksumConverter instance_;
        return instance_;
    }

    const std::string& checksumToString(unsigned int checksum) const {
        const int checksumBase256 = checksum % CHECKSUM_BASE;
        return this->checksumToStringMap_[checksumBase256];
    }

    static const int CHECKSUM_BASE = 256;

private:
    ChecksumConverter();
    virtual ~ChecksumConverter();

    const char* get_padding_zeros(int checksumBase256) const;

    std::string checksumToStringMap_[CHECKSUM_BASE];
};

}

#endif  // FIXPARSER_CPP_SRC_MAIN_FIXPARSER_CHECKSUMCONVERTER_H_
